All Packages Class Hierarchy This Package Previous Next Index
Class sun.server.util.SimpleHashtable
java.lang.Object
|
+----java.util.Dictionary
|
+----sun.server.util.SimpleHashtable
- public class SimpleHashtable
- extends Dictionary
- implements Cloneable
This class implements a hashtable based on java.util.Hashtable.
This hashtable is not extensible; the size is set as part of
the constructor. However, it does allow for unsynchronized get
operations. It does not support serialization. It uses
String.hashCode() (when the object is a String), which is known
to have problems for long strings.
- See Also:
- Hashtable, equals, hashCode
-
SimpleHashtable()
- Constructs a new, empty hashtable with a default capacity.
-
SimpleHashtable(int)
- Constructs a new, empty hashtable with the specified initial
capacity.
-
clear()
- Clears this hashtable so that it contains no keys.
-
contains(Object)
- Tests if some key maps into the specified value in this hashtable.
-
containsKey(Object)
- Tests if the specified object is a key in this hashtable.
-
elements()
- Returns an enumeration of the values in this hashtable.
-
get(Object)
- Returns the value to which the specified key is mapped in this hashtable.
-
isEmpty()
- Tests if this hashtable maps no keys to values.
-
keys()
- Returns an enumeration of the keys in this hashtable.
-
put(Object, Object)
- Maps the specified
key
to the specified
value
in this hashtable.
-
remove(Object)
- Removes the key (and its corresponding value) from this
hashtable.
-
size()
- Returns the number of keys in this hashtable.
-
toString()
- Returns a rather long string representation of this hashtable.
SimpleHashtable
public SimpleHashtable(int initialCapacity)
- Constructs a new, empty hashtable with the specified initial
capacity.
- Parameters:
- initialCapacity - the initial capacity of the hashtable.
- Throws: IllegalArgumentException
- if the initial capacity is less
than or equal to zero.
SimpleHashtable
public SimpleHashtable()
- Constructs a new, empty hashtable with a default capacity.
size
public int size()
- Returns the number of keys in this hashtable.
- Returns:
- the number of keys in this hashtable.
- Overrides:
- size in class Dictionary
isEmpty
public boolean isEmpty()
- Tests if this hashtable maps no keys to values.
- Returns:
-
true
if this hashtable maps no keys to values;
false
otherwise.
- Overrides:
- isEmpty in class Dictionary
keys
public synchronized Enumeration keys()
- Returns an enumeration of the keys in this hashtable.
- Returns:
- an enumeration of the keys in this hashtable.
- Overrides:
- keys in class Dictionary
- See Also:
- Enumeration
elements
public synchronized Enumeration elements()
- Returns an enumeration of the values in this hashtable.
Use the Enumeration methods on the returned object to fetch the elements
sequentially.
- Returns:
- an enumeration of the values in this hashtable.
- Overrides:
- elements in class Dictionary
- See Also:
- Enumeration, keys
contains
public boolean contains(Object value)
- Tests if some key maps into the specified value in this hashtable.
This operation is more expensive than the
containsKey
method.
- Parameters:
- value - a value to search for.
- Returns:
-
true
if some key maps to the
value
argument in this hashtable;
false
otherwise.
- Throws: NullPointerException
- if the value is
null
.
containsKey
public boolean containsKey(Object key)
- Tests if the specified object is a key in this hashtable.
- Parameters:
- key - possible key.
- Returns:
-
true
if the specified object is a key in this
hashtable; false
otherwise.
get
public Object get(Object key)
- Returns the value to which the specified key is mapped in this hashtable.
- Parameters:
- key - a key in the hashtable.
- Returns:
- the value to which the key is mapped in this hashtable;
null
if the key is not mapped to any value in
this hashtable.
- Overrides:
- get in class Dictionary
put
public synchronized Object put(Object key,
Object value)
- Maps the specified
key
to the specified
value
in this hashtable. Neither the key nor the
value can be null
.
The value can be retrieved by calling the get
method
with a key that is equal to the original key.
- Parameters:
- key - the hashtable key.
- value - the value.
- Returns:
- the previous value of the specified key in this hashtable,
or
null
if it did not have one.
- Throws: NullPointerException
- if the key or value is
null
.
- Overrides:
- put in class Dictionary
remove
public synchronized Object remove(Object key)
- Removes the key (and its corresponding value) from this
hashtable. This method does nothing if the key is not in the hashtable.
- Parameters:
- key - the key that needs to be removed.
- Returns:
- the value to which the key had been mapped in this hashtable,
or
null
if the key did not have a mapping.
- Overrides:
- remove in class Dictionary
clear
public synchronized void clear()
- Clears this hashtable so that it contains no keys.
toString
public synchronized String toString()
- Returns a rather long string representation of this hashtable.
- Returns:
- a string representation of this hashtable.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index